

package net.mtg;

import net.mtg.io.*;
import java.util.*;

public class MTGStack {

    List<MTGCard> internalStack = new ArrayList<MTGCard>();
    
    public MTGStack(){
    }

    public void pushSpell(MTGCard card){
	internalStack.add(card);
    }

    public MTGCard popSpell(){
	return internalStack.remove(internalStack.size() - 1);
    }

    public void resolve(MTGEnviroment env){
	while (internalStack.size() > 0){
	    MTGCard card = popSpell();
	    card.runAbilities(env);
	}
    }

    public void removeSpell(MTGCard card){
	for (int i = 0; i < internalStack.size(); i++){
	    if (internalStack.get(i).equals(card)){
		removeSpell(i);
	    }
	}
    }

    public MTGCard removeSpell(int index){
	return internalStack.remove(index);
    }

    public List<MTGCard> getInternalStackList(){
	return internalStack;
    }

}